package operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-11-02
 * Time: 10:55
 */
public class FindBook implements IOPeration{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书...");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入您要查找的图书的名字");
        String name = sc.nextLine();

        int currency = bookList.getUsedSize();
        for (int i = 0; i < currency; i++) {
            Book book = bookList.getBooks(i);
            if (book.getName().equals(name)){
                System.out.println("找到这本书了，书籍内容如下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("找不到这本书!");
    }
}
